<style>
  .swhoAddress select{
    /*清除select的边框样式*/
    border: none;
    /*清除select聚焦时候的边框颜色*/
    outline: none;
    /*隐藏select的下拉图标*/
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
  }
</style>
<div class="wrapper">
  <?php $this->partial('Common/mainHeader');?>

  <?php $this->partial('Common/mainSiderbar');?>

  <div class="content-wrapper">
    <section class="content-header">
      <h1>区域代表</h1>
      <ol class="breadcrumb">
        <li><a href="/"><i class="fa fa-fw fa-home"></i> 首页</a></li>
        <li class="active"> 区域代表</li>
      </ol>
    </section>
    <div class="content">
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">区域代表</h3>
          <div class="box-tools pull-right">
            <form method="get" class="form-inline">
              <div class="pull-left margin-r-5" id="selectAddress">
                <select class="form-control" name="province_code"></select>
                <select class="form-control" name="city_code"></select>
                <select class="form-control" name="district_code"></select>
              </div>
              <button type="submit" class="btn btn-sm btn-success">搜索</button>
            </form>
          </div>
        </div>

        <div class="box-body">
          <table class="table table-bordered table-condensed">
            <tbody>
              <tr>
                <th>申请日期</th>
                <th>会员编号</th>
                <th>服务中心</th>
                <th>负责人</th>
                <th>详细地址</th>
                <th>状态</th>
              </tr>
              <?php foreach($pager as $page) { ?>
              <tr>
                <td><?php echo date('Y-m-d H:m:s', $page -> create_time); ?></td>
                <td><?php echo $page -> user_code; ?></td>
                <td><?php echo $page -> u_real_name . $page -> user_code; ?></td>
                <td><?php echo $page -> real_name; ?></td>
                <td
                  class="swhoAddress"
                  data-toggle="distpicker"
                  data-autoselect="3"
                  data-value-type="code"
                  data-province="<?php echo substr($page -> address_code, 0, 2) . '0000' ?>"
                  data-city="<?php echo substr($page -> address_code, 0, 4) . '00' ?>"
                  data-district="<?php echo  $page -> address_code ?>"
                >
                  <select disabled></select>
                  <select disabled></select>
                  <select disabled></select>
                  <span><?php echo $page -> address_detail; ?></span>
                </td>
                <td>
                  <?php
                  switch($page -> status) {
                    case 1:
                      echo '审核中';
                      break;
                    case 2:
                      echo '审核不通过';
                      break;
                    case 9:
                      echo '正常';
                      break;
                  }
                  ?></td>
              </tr>
              <?php } ?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>

  <?php $this->partial('Common/mainFooter');?>
</div>

<?php $this->partial('Common/mainScript');?>
<script type="text/javascript" charset="utf-8" src="/node_modules/distpicker/dist/distpicker.min.js"></script>

<script type="text/javascript">
  $(document).ready(function() {
    $.fn.distpicker.setDefaults({
      valueType: "code"
    });

    var addressCode = <?php echo json_encode($get); ?>,
      addressCodeJson;

    if(addressCode.toString() !== '0') {
      addressCodeJson = {
        province: addressCode.province_code,
        city: addressCode.city_code,
        district: addressCode.district_code
      };
    } else {
      addressCodeJson = {};
    }

    var dId = $("#selectAddress").distpicker(addressCodeJson);
    console.log(dId.distpicker('getDistricts'));
    
    var showProvinceTd = $(".showProvince");
    showProvinceTd.each(function() {
      //console.log(dId.distpicker('getDistricts')[$(this).data('value')]);
      //$(this).distpicker('getDistricts', $(this).data('value'));
      //console.log(distpicker.distpicker('getDistricts', 210000), $(this).data('value'));
    });
    var showCityTd = $(".showCity");
    var showDistrictTd = $(".showDistrict");
  });
</script>